package woordvoorspeller.core;

/**
 * WordListEntry represents an entry in the WordList. Each entry has
 * a word and a priority. 
 * @author Brian Setz
 * @version 0.1
 */
public class WordListEntry implements Comparable<WordListEntry>
{
	private String word;
	private int priority;
	
	/**
	 * Creates a WordListEntry.
	 * @param word The word for the entry.
	 * @param priority The priority of the enter.
	 */
	public WordListEntry(String word, int priority)
	{
		this.word = word;
		this.priority = priority; 
	}
	
	/**
	 * Compares WordListEntry's with each other. The priority is compared, if those are equals then the words are compared.
	 * @param entry The entry to compare.
	 */
	public int compareTo(WordListEntry entry) {
		if(entry.getPriority() > this.getPriority())
			return 1;
		if(entry.getPriority() == this.getPriority())
			return (this.getWord().compareTo(entry.getWord()));
		else
			return 0;
	}
	
	/**
	 * The toString representation of the WordListEntry is the word.
	 */
	public String toString()
	{
		return this.getWord();
	}
	
	/**
	 * Retrieves the word of the WordListEntry.
	 * @return The word.
	 */
	public String getWord() 
	{
		return word.toLowerCase();
	}

	/**
	 * Sets the word of the WordListEntry.
	 * @param word The word to set.
	 */
	public void setWord(String word) 
	{
		this.word = word;
	}

	/**
	 * Retrieves the priority of the WordListEntry
	 * @return The priority.
	 */
	public int getPriority() 
	{
		return priority;
	}

	/**
	 * Sets the priority of the WordListEntry.
	 * @param priority The priority to set.
	 */
	public void setPriority(int priority) 
	{
		this.priority = priority;
	}	
}
